<!--会员钱包变化记录管理-->
<template>
  <div id="memberUserWalletChange" class="app-container">
    <!--列表-->
    <div class="table-container flex-main">
      <el-table
        ref="multipleTable"
        :data="list"
        header-cell-class-name="table-header"
        fit
        height="100%"
        highlight-current-row
        @sort-change="sortChange">
        <el-table-column align="center" prop="id" label="#" width="60">
          <template slot-scope="scope">{{ scope.$index+1 }}</template>
        </el-table-column>
        <el-table-column label="类型" prop="type" width="100" sortable show-overflow-tooltip>
          <template slot-scope="scope">
            <el-tag v-if="scope.row.type === 0" type="danger">消费</el-tag>
            <el-tag v-if="scope.row.type === 1">进账</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="变化金额" prop="changeNumber" width="150" show-overflow-tooltip>
          <template slot-scope="scope">
            <span class="color-danger" style="font-size: 15px;font-weight: bold;">{{ scope.row.changeNumber |formatPrice }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="gmtCreated" sortable label="变化时间" width="160">
          <template slot-scope="scope">{{ scope.row.gmtCreated | formatDate }}</template>
        </el-table-column>
        <el-table-column label="备注" prop="remark" min-width="200" show-overflow-tooltip />
      </el-table>
    </div>
    <div class="pagination_handler">
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" />
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    memberId: {
      type: String,
      default: null
    }

  },

  data() {
    return {
      list: [],
      total: 0,
      listQuery: {
        page: 1,
        limit: this.common.PAGE_LIMIT_DEFAULT,
        keyword: undefined,
        sort: this.common.SORT_DEFAULT
      },

      multipleSelectionRecords: []
    }
  },
  watch: {
    memberId: {
      handler(val) {
        if (val) {
          this.listQuery = {
            ...this.listQuery,
            memberId: val
          }
          this.fetchData()
        }
      },
      immediate: true
    }
  },
  created() {
  },
  methods: {
    // 表格自带方法开始
    /* 表格列排序*/
    sortChange(data) {
      const { prop, order } = data
      if (prop) {
        if (order === 'ascending') {
          this.listQuery.sort = '+' + prop
        } else {
          this.listQuery.sort = '-' + prop
        }
      } else {
        this.listQuery.sort = this.common.SORT_DEFAULT
      }
      this.handleFilter()
    },
    // 表格自带方法结束

    /* 搜索*/
    handleFilter() {
      this.listQuery = {
        ...this.listQuery,
        page: 1
      }
      this.fetchData()
    },
    /* 重置*/
    handleReset() {
      this.listQuery = {
        ...this.listQuery,
        page: 1,
        limit: this.common.PAGE_LIMIT_DEFAULT,
        keyword: undefined,
        sort: this.common.SORT_DEFAULT
      }
      this.$refs.multipleTable.clearFilter()
      this.$refs.multipleTable.clearSort()
      this.fetchData()
    },
    async fetchData() {
      const response = await this.$store.dispatch('memberUserWalletChangePage', this.listQuery)
      this.list = response.records
      this.total = response.total
    }
  }
}
</script>
    <style lang="scss" scoped>
    </style>

